package algorithms.collection;

import java.util.*;

/**
 * 计算交集，并集，差集
 */
public class CollectionTest {

    public static void main(String[] args) {

       // HashSet set1 = new HashSet();
       // HashSet set2 = new HashSet();
        ArrayList<Object> set1 = new ArrayList<>();
        ArrayList<Object> set2 = new ArrayList<>();
        for(int i =1;i<=6;i++){
            set1.add(i);
            set2.add(i+3);
        }
        System.out.println("set1："+set1);
        System.out.println("set2："+set2);

        set1.retainAll(set2);
        System.out.println("交集："+set1);

        //set1.removeAll(set2);
        //System.out.println("差集："+set1);

        //set1.addAll(set2);
        //System.out.println("并集："+set1);

    }

}
